#!/bin/bash
source /etc/profile

# 可输入使其，如无输入值，取昨天的日期
if [ -n "$1" ]
then 
    do_date=$1
else
    do_date=`date -d "-1 day" +%F`
fi

sql="
-- 按照最长连续活跃天数分组统计用户数量（连续活跃天数为1-7天）
insert overwrite table ads.ads_member_active_continuous_cnt partition(dt='$do_date')
select 
    max_continuous_day,
    count(*)
from dws.dws_member_start_last_7_day
where dt ='$do_date'
group by max_continuous_day;
"

hive -e "$sql"